home *** CD-ROM | disk | FTP | other *** search
- function setBonus()
- {
- if(rowLength == tilesToRow)
- {
- bonus += rowBonus;
- rowsKilledBonus += rowBonus;
- }
- else
- {
- bonus += rowBonus * 2;
- rowsKilledBonus += rowBonus * 3;
- }
- }
- function levelCheck()
- {
- level = Math.floor(score / 2500) + 1;
- if(level != preLevel)
- {
- preLevel = level;
- bonus += (tilesMax - getTilesOnBoard()) * 25;
- score += bonus;
- mcSounds.gotoAndPlay("levelBonus");
- mcBonus.bonus = bonus;
- mcBonus.play();
- }
- }
- function startKillAnim(pNr)
- {
- if(aBoard[pNr] != 0)
- {
- var newTile = mcTile.duplicateMovieClip("mcTile" + depth,depth++);
- newTile.gotoAndStop(aBoard[pNr] + 1);
- newTile._x = this["mcTile" + pNr]._x;
- newTile._y = this["mcTile" + pNr]._y;
- newTile.delay = rndNumber(1,10,0);
- newTile.g = 1;
- newTile.onEnterFrame = function()
- {
- if(--this.delay <= 0)
- {
- this.g *= 1.33;
- this._y += this.g;
- if(this._y > 480)
- {
- this.removeMovieClip();
- }
- }
- };
- }
- }
- function checkTile()
- {
- tileNr = getBoardPos(posCounter);
- fNr = aBoard[tileNr];
- if(fNr == 0)
- {
- return sub1();
- }
- var link = getLink(tileNr,0);
- if(link == 0)
- {
- subNeighbour("row");
- return sub3();
- }
- return sub3();
- }
- function sub1()
- {
- if(++posCounter == xMax)
- {
- posCounter = 0;
- if(++row == yMax)
- {
- return false;
- }
- return sub2();
- }
- return sub2();
- }
- function sub2()
- {
- lResult = checkTile();
- if(lResult == false)
- {
- return false;
- }
- return fNr;
- }
- function sub3()
- {
- var link = getLink(tileNr,1);
- if(link == 0)
- {
- subNeighbour("col");
- return sub1();
- }
- return sub1();
- }
- function subNeighbour(pLine)
- {
- if(pLine == "row")
- {
- if(xMax - posCounter >= tilesToRow)
- {
- this["aTilesToKillRow" + row].push(tileNr);
- var i = posCounter + 1;
- while(i < xMax)
- {
- var tNr = getBoardPos(i);
- var nNr = aBoard[tNr];
- setLink(getBoardPos(i - 1),0,nNr);
- if(nNr == 0 || nNr != fNr)
- {
- if(this["aTilesToKillRow" + row].length < tilesToRow)
- {
- this["aTilesToKillRow" + row] = [];
- }
- return undefined;
- }
- this["aTilesToKillRow" + row].push(tNr);
- i++;
- }
- }
- }
- else if(yMax - row >= tilesToRow)
- {
- var tempRow = row;
- this["aTilesToKillCol" + posCounter].push(tileNr);
- var i = tempRow + 1;
- while(i < yMax)
- {
- row = i;
- var tNr = getBoardPos(posCounter);
- var nNr = aBoard[tNr];
- row = i - 1;
- setLink(getBoardPos(posCounter),1,nNr);
- row = i;
- if(nNr == 0 || nNr != fNr)
- {
- if(this["aTilesToKillCol" + posCounter].length < tilesToRow)
- {
- this["aTilesToKillCol" + posCounter] = [];
- }
- row = tempRow;
- return undefined;
- }
- this["aTilesToKillCol" + posCounter].push(tNr);
- i++;
- }
- row = tempRow;
- }
- }
- bonus = 0;
- depth = 1000;
- score += time;
- clearLinks();
- initCheck();
- lResult = checkTile();
- var i = 0;
- while(i < yMax)
- {
- rowLength = this["aTilesToKillRow" + i].length;
- if(rowLength != 0)
- {
- playSound("killRow");
- while(this["aTilesToKillRow" + i].length > 0)
- {
- tileNr = this["aTilesToKillRow" + i].shift();
- startKillAnim(tileNr);
- aBoard[tileNr] = 0;
- }
- setBonus();
- }
- i++;
- }
- var i = 0;
- while(i < xMax)
- {
- rowLength = this["aTilesToKillCol" + i].length;
- if(rowLength != 0)
- {
- playSound("killRow");
- while(this["aTilesToKillCol" + i].length > 0)
- {
- tileNr = this["aTilesToKillCol" + i].shift();
- startKillAnim(tileNr);
- aBoard[tileNr] = 0;
- }
- setBonus();
- }
- i++;
- }
- if(getTilesOnBoard() == 0)
- {
- bonus += 1000;
- rowsKilledBonus += rowBonus * 2;
- }
- if(bonus != 0)
- {
- score += bonus;
- levelCheck();
- mcBonus.bonus = bonus;
- mcBonus.play();
- }
- else
- {
- levelCheck();
- }
- if(rowsKilledBonus / rowBonusFactor >= 1 && tilesOnBoard >= criticalAmount)
- {
- rowsKilledBonus -= rowBonusFactor;
- initTimer();
- time = int(time * 1.5);
- gotoAndStop(12);
- }
- else
- {
- makeNewTile();
- initTimer();
- gotoAndStop(8);
- }
-